#include "Enemy.h"

//-- Implementation of the enemy class
Enemy::Enemy():mDead(false), mOffsetY(0.01f), mOffsetZ(0.04f)
{
	mHealthMesh = Meshes::PlaneMesh;
	mHealth = 1.5f;
	mHealthBar.Init(mHealthMesh);
}

Enemy::~Enemy(){};

//-- Update the enemy health bar
void Enemy::UpdateHealthBar(abfw::Matrix44 origin)
{
	//-- Correctly scale the health bar
	abfw::Matrix44 healthScale;
	healthScale.Scale(abfw::Vector3(mHealth,0.5f,0.3f));

	//-- Rotate
	abfw::Matrix44 healthRotate;
	healthRotate.RotationX(45);

	//-- Position above the the enemy
	origin.SetTranslation(abfw::Vector3(origin.GetTranslation().x,
										origin.GetTranslation().y+mOffsetY, 
										origin.GetTranslation().z+mOffsetZ));

	//-- Set the final transform
	mHealthBar.SetTransform(healthScale * origin);
}

//-- Sets the rotation angle of the enemy
void Enemy::SetRotationAngle(float angle)
{
	mDirection = angle;
}


//-- Returns the current enemy angle
float Enemy::GetAngle()
{
	return mDirection;
}

//-- Returns the enemys origin
abfw::Matrix44 Enemy::GetOrigin()
{
	return mOrigin;
}

//-- Returns the vector that the enemy is current targeting
abfw::Vector3 Enemy::GetTarget()
{
	return mTarget;
}

//-- Returns the current velocity of the enemy
abfw::Vector3 Enemy::GetVelocity()
{
	return mVelocity;
}

//-- Set the enemy velocity
void Enemy::SetVelocity(abfw::Vector3 velocity)
{
	mVelocity = velocity;
}

//-- Set the enemy origin
void Enemy::SetOrigin(abfw::Matrix44 marker)
{
	mOrigin = marker;
}

//-- Set the enemy target vector
void Enemy::SetTarget(abfw::Vector3 target)
{
	mTarget = target;
}

//-- Set to true when the enemy is dead
void Enemy::SetDead(bool dead)
{
	mDead = dead;
}

//-- Returns true if the enemy is dead
bool Enemy::IsDead()
{
	return mDead;
}

//-- Returns the current health of the enemy
float Enemy::GetHealth()
{
	return mHealth;
}
//-- Decrease the enemy health by the given amount
void Enemy::DecreaseHealth(float amount)
{
	mHealth -= amount;
}

GameObject& Enemy::GetHealthBar()
{
	return mHealthBar;
}





